﻿/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2012-2018. All rights reserved.
 * Description:
 * Author: 辛爱国 x30005137
 * Create: 2020-07-28
 * Notes: 无
 */
#include "errortoast.h"
#include "IdeaShareDef.h"
#include <QObject>
#include <QString>
#include <iostream>


QString strerrno(ShareAppErr &toast)
{
//    static QMap<IDEASHARE_ERROR_ID, QString> errno_str_map = { { IDEASHARE_ERROR_SUCCESS, QObject::tr("Success.") },
//                                                               { IDEASHARE_ERROR_CONNECT_FAIL,
//                                                                 QObject::tr("Connection failed. Check whether the computer and endpoint are on the same network.") },
//                                                               { IDEASHARE_ERROR_INVALID_ENDPOINT_PARAM, QObject::tr("Connection failed. Check the IP address is correct.") },
//                                                               { IDEASHARE_ERROR_CONNECT_WRONG_PWD, QObject::tr("Connect failed. Projection code is incorrect or expired.") },
//                                                               { IDEASHARE_ERROR_CONNECT_BUSY, QObject::tr("The number of connections has reached the maximum.") },
//                                                               { IDEASHARE_ERROR_CONNECT_REJECT, QObject::tr("Access denied. Please try again.") },
//                                                               { IDEASHARE_ERROR_CONNECT_UPDATING, QObject::tr("The device is being upgraded. Please try again later.") },
//                                                               { IDEASHARE_ERROR_CONNECT_INTERUPT, QObject::tr("Connection interrupted.") },
//                                                               { IDEASHARE_ERROR_SYSTEM_ABNORMITY, QObject::tr("The system is being recovered. Please try again later.") },
//                                                               { IDEASHARE_ERROR_IN_CONNECTION, QObject::tr("The client already has an active connection.") },
//                                                               { IDEASHARE_ERROR_NO_SUPPORT_AIRAUX, QObject::tr("This conference does not support presentation sharing.") },
//                                                               { IDEASHARE_ERROR_NO_AIRAUX_CAPS, QObject::tr("Data format unsupported.") },
//                                                               { IDEASHARE_ERROR_SEND_AUX_FAIL, QObject::tr("Failed to share a presentation.") },
//                                                               { IDEASHARE_ERROR_WEB_DENY,
//                                                                 QObject::tr("Connection failed. The web interface is disabled. Contact the administrator.") },
//                                                               { IDEASHARE_ERROR_USER_LOCK,
//                                                                 QObject::tr("Projection code attempts exceeded. The client has been locked. Please try again 5 minutes later.") },
//                                                               { IDEASHARE_ERROR_SHARE_NOTCONNECT, QObject::tr("Unconnected when sharing.") },
//                                                               { IDEASHARE_ERROR_SHARE_ALREADY, QObject::tr("Sharing presentation.") },
//                                                               { IDEASHARE_ERROR_GENERAL_ERROR, QObject::tr("Gerneral error.") },
//                                                               { IDEASHARE_ERROR_PARAM_ERROR, QObject::tr("Param error.") },
//                                                               { IDEASHARE_ERROR_MEM_ERROR, QObject::tr("Memery malloc error.") },
//                                                               { IDEASHARE_ERROR_SYSTEM_ERROR, QObject::tr("System error.") },
//                                                               { IDEASHARE_ERROR_MSG_ERROR, QObject::tr("Send Message error.") },
//                                                               { IDEASHARE_ERROR_CFG_ERROR, QObject::tr("Get system config error.") },
//                                                               { IDEASHARE_ERROR_PASSWORD_EXPIRE,
//                                                                 QObject::tr("Connect failed. Projection code is incorrect or expired. Please check it and try again .") },
//                                                               { IDEASHARE_ERROR_CAN_NOT_FIND_LINK, QObject::tr("Can't find link.") },
//                                                               { IDEASHARE_ERROR_SOCKET_SEND_FAIL, QObject::tr("Socket send fail.") },
//                                                               { IDEASHARE_ERROR_VERIFY_TIMEOUT,
//                                                                 QObject::tr("The time allowed for entering a projection code has expired. Please try again.") },
//                                                               { IDEASHARE_ERROR_CONNECT_DNS_FAIL, QObject::tr("DNS resolution of the connection address failed.") },
//                                                               { IDEASHARE_ERROR_CONNECT_DNS_TIMEOUT, QObject::tr("DNS resolution of the connection address timed out.") },
//                                                               { IDEASHARE_ERROR_WEBCTRL_ALIVET_TIMEOUT,
//                                                                 QObject::tr("Persistent connection of the web control channel timed out.") },
//                                                               { IDEASHARE_ERROR_WEBCTRL_OPR_ERROR, QObject::tr("Incorrect web control operation type.") },
//                                                               { IDEASHARE_ERROR_WEBCTRL_REV_ERROR, QObject::tr("The web control channel failed to receive data.") },
//                                                               { IDEASHARE_ERROR_WEBCTRL_RES_TIMEOUT, QObject::tr("Web control operation response timed out.") },
//                                                               { IDEASHARE_ERROR_WEBCTRL_SESSIONID_FAIL, QObject::tr("The web control channel failed to obtain SessionID.") },
//                                                               { IDEASHARE_ERROR_MICSWITCH_TYPEERROR, QObject::tr("Incorrect microphone switch type.") },
//                                                               { IDEASHARE_ERROR_WEBCTRL_LOGOUT_TIMEOUT, QObject::tr("Web control logout timed out.") },
//                                                               { IDEASHARE_ERROR_NO_PASSWORD_IN_FORBIDDEN,
//                                                                 QObject::tr("Connection failed. Enter projection code to connect.") },
//                                                               { IDEASHARE_ERROR_NO_PASSWORD_IN_WND_EXIST, QObject::tr("The device is busy. Please try again later.") },
//                                                               { IDEASHARE_ERROR_NO_AIRAUX_WITH_LOW_BANDWIDTH,
//                                                                 QObject::tr("The bandwidth is too low. Presentation sharing is not allowed.") },
//                                                               { IDEASHARE_ERROR_CONF_NO_AUX_CAP,
//                                                                 QObject::tr("Presentation sharing is not supported in this meeting. (A message is displayed.)") },
//                                                               { IDEASHARE_ERROR_PROCESS_CONNECTING, QObject::tr("Connecting. Please wait.") },
//                                                               { IDEASHARE_ERROR_CONNECT_INTERUPT_BY_HEARTBREAK, QObject::tr("The current network is in poor condition. The connection is disconnected.") },
//                                                               { IDEASHARE_ERROR_CONNECT_WEB_ACCEPT, QObject::tr("Web accepted") },
//                                                               { IDEASHARE_ERROR_CONNECT_RIGHT_PWD, QObject::tr("Correct projection code.") },
//                                                               { IDEASHARE_ERROR_MULTICONNECT_TERMINAL_BUSY, QObject::tr("The device is busy. Please try again later.") },
//                                                               { IDEASHARE_ERROR_AUDIO_DEVICE_NOT_EXIST, QObject::tr("No audio device exists.") },
//                                                               { IDEASHARE_ERROR_DISCONNECTED_BY_TERM, QObject::tr("The connection is terminated by the endpoint.") },
//                                                               { IDEASHARE_ERROR_BUTT, QObject::tr("Connection failed. Please reconnect or contact the administrator.") } };

    static QMap<ShareAppErr, QString> errno_str_map = {{CONNECT_ERROR, QObject::tr("Connection failed. Check whether the computer and endpoint are on the same network.")},
                                                              {AUTH_ERROR,QObject::tr("Connect failed. Projection code is incorrect or expired.")},
                                                              {CLIENT_IS_LOCKED_ERROR,QObject::tr("Projection code attempts exceeded. The client has been locked. Please try again 5 minutes later.")},
                                                              {PROJECTION_CODE_ERROR,QObject::tr("Can not mixed digit and character")},
                                                              {CONNECT_BUSY_ERROR,QObject::tr("The number of connections has reached the maximum.")},
                                                              {IN_CONNECTION_ERROR,QObject::tr("The client already has an active connection.")},
                                                              {CONF_NO_DATA_CAP_ERROR,QObject::tr("Presentation sharing is not supported in this meeting. (A message is displayed.)")},
                                                              {MULTICONNECT_BUSY_ERROR,QObject::tr("The device is busy. Please try again later.")}};
    if (errno_str_map.contains(toast)) {
        return errno_str_map[toast];
    } else {
        return QObject::tr("Unkonwn Error ID : %1.").arg(toast);
    }
}
